import { IPSAppMethodDTO } from '../ipsapp-method-dto';
import { IPSApplication } from '../ipsapplication';
import { IPSAppDEMethodDTO } from './ipsapp-demethod-dto';
import { IPSAppDEMethodDTOField } from './ipsapp-demethod-dtofield';
import { IPSAppDataEntity } from './ipsapp-data-entity';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppDEMethodDTOImpl extends PSModelObjectImpl implements IPSAppDEMethodDTO {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappdemethoddtofields: IPSAppDEMethodDTOField[] | null = null;

  getPSAppDEMethodDTOFields(): IPSAppDEMethodDTOField[] | null {
    if (this.psappdemethoddtofields == null) {
      this.psappdemethoddtofields = this.fillChildListModel(this.M.getPSAppDEMethodDTOFields, 'app.dataentity.IPSAppDEMethodDTOField') as IPSAppDEMethodDTOField[];
    }
    return this.psappdemethoddtofields;
  }

  get psAppDEMethodDTOFields(): IPSAppDEMethodDTOField[] | null {
    return this.getPSAppDEMethodDTOFields();
  }

  findPSAppDEMethodDTOField(objKey: any): IPSAppDEMethodDTOField | null {
    return this.getPSModel5('app.dataentity.IPSAppDEMethodDTOField', this.getPSAppDEMethodDTOFields(), objKey) as IPSAppDEMethodDTOField;
  }

  protected refpsappdemethoddto: IPSAppDEMethodDTO | null = null;

  getRefPSAppDEMethodDTO(): IPSAppDEMethodDTO | null {
    if (this.refpsappdemethoddto != null) return this.refpsappdemethoddto;
    const value = this.M.getRefPSAppDEMethodDTO;
    if (value == null) {
      return null;
    }
    this.refpsappdemethoddto = this.getRefPSAppDataEntityMust().findPSAppDEMethodDTO(value);
    return this.refpsappdemethoddto;
  }

  get refPSAppDEMethodDTO(): IPSAppDEMethodDTO | null {
    return this.getRefPSAppDEMethodDTO();
  }

  getRefPSAppDEMethodDTOMust(): IPSAppDEMethodDTO {
    const value = this.getRefPSAppDEMethodDTO();
    if (value == null) {
      throw new Error('未指定引用应用实体DTO');
    }
    return value;
  }

  protected refpsappdataentity: IPSAppDataEntity | null = null;

  getRefPSAppDataEntity(): IPSAppDataEntity | null {
    if (this.refpsappdataentity != null) return this.refpsappdataentity;
    const value = this.M.getRefPSAppDataEntity;
    if (value == null) {
      return null;
    }
    this.refpsappdataentity = this.getPSModel4('app.dataentity.IPSAppDataEntity', value, 'getRefPSAppDataEntity') as IPSAppDataEntity;
    return this.refpsappdataentity;
  }

  get refPSAppDataEntity(): IPSAppDataEntity | null {
    return this.getRefPSAppDataEntity();
  }

  getRefPSAppDataEntityMust(): IPSAppDataEntity {
    const value = this.getRefPSAppDataEntity();
    if (value == null) {
      throw new Error('未指定引用应用实体');
    }
    return value;
  }

  get sourceType(): 'DE' | 'DYNAMODEL' | 'DEACTIONINPUT' | 'DEFILTER' | 'REFDE' | 'DEDATASETINPUT' {
    return this.M.sourceType;
  }

  protected srcpsappmethoddto: IPSAppMethodDTO | null = null;

  getSrcPSAppMethodDTO(): IPSAppMethodDTO | null {
    if (this.srcpsappmethoddto != null) return this.srcpsappmethoddto;
    const value = this.M.getSrcPSAppMethodDTO;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.srcpsappmethoddto = ipsapplication.findPSAppMethodDTO(value);
    }
    return this.srcpsappmethoddto;
  }

  get srcPSAppMethodDTO(): IPSAppMethodDTO | null {
    return this.getSrcPSAppMethodDTO();
  }

  getSrcPSAppMethodDTOMust(): IPSAppMethodDTO {
    const value = this.getSrcPSAppMethodDTO();
    if (value == null) {
      throw new Error('未指定源应用DTO');
    }
    return value;
  }

  get type(): 'DEFAULT' | 'DEACTIONINPUT' | 'DEFILTER' | 'DEDATASETINPUT' {
    return this.M.type;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSAppDEMethodDTOImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.IPSApplicationObject' || cls == 'app.dataentity.IPSAppDEMethodDTO') return true;
    return super.instanceof(cls);
  }
}
